#!/usr/bin/python
#coding:utf8
'''
Decorator
'''

import time
def timeSpend(func):
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print('time spend: %.2f' % (end - start))
        return result
    return wrapper

@timeSpend
def test(num=1):
    print('test')
    for i in range(num):
        time.sleep(2)

if __name__ == '__main__':
    test(2)